library(here)
setwd(here())
library(readr)
library(dplyr)
cppg <- read_delim("data/raw/AJPS_CPPG_pledges_10April2017.tab", delim = "\t")
cppg <- cppg %>% filter(govparty==1)
us <- cppg %>% filter(USdum==1 & govparty==1) 

table(us$year, us$fulfil2)

# Bush's big questionable promise was in 1988

# second highest level of promise keeping amongst US Presidents
prop.table(table(us$year, us$fulfil2), 1)



table(cppg$idmanifesto)
completion.rates.ruling.party <- tapply(cppg$fulfil2, cppg$idmanifesto, mean)
length(unique(cppg$idmanifesto))

length(completion.rates.ruling.party)

hist(completion.rates.ruling.party)
sd.cppg.fulfil  <- sd(completion.rates.ruling.party)
save(sd.cppg.fulfil, file = "data/intermediate/sd.cppg.fulfil.rda")
